package sim.states;

import sim.Image;
import sim.misc.Holder;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.math.Matrix4;
/** Class for drawing and updating your game, should be used as the main element in your game. Extend this.
 * 
 * @author Derek
 *
 */


public abstract class BasicGame implements ApplicationListener, InputProcessor 
{
	

	
	protected final Matrix4 viewMatrix = new Matrix4();
	public final Matrix4 transformMatrix = new Matrix4();
	public abstract void update(float delta);
	public abstract void draw();
	public abstract void init();
	public OrthographicCamera camera;
	public AssetManager assestManager;
	

	@Override
	public void resize(int width, int height)
	{
		// TODO Auto-generated method stub
		
	}
	/**Sets the world size of your game. Actual pixel size will be determined by other means.
	 * 
	 * @param width
	 * @param height
	 */
	public void setWorldSize(float width, float height)
	{
		viewMatrix.setToOrtho2D(0, 0, width, height);
		camera = new OrthographicCamera(width, height);
	}

	

	@Override
	public void pause()
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume()
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose()
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean keyDown(int keycode)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean keyUp(int keycode)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean keyTyped(char character)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchDown(int x, int y, int pointer, int button)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchUp(int x, int y, int pointer, int button)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchDragged(int x, int y, int pointer)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchMoved(int x, int y)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean scrolled(int amount)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void create()
	{
		
		
		camera = new OrthographicCamera(67, 10, 6);
		
		init();
		camera.translate(camera.viewportWidth / 2, camera.viewportHeight / 2, 0);
		
		
	}

	@Override
	public void render()
	{
		
		//Holder.b.setTransformMatrix(transformMatrix);
		//Holder.b.setProjectionMatrix(viewMatrix);
		camera.update();
		camera.apply(Gdx.gl10);
		Holder.b.setProjectionMatrix(camera.combined);
		
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		

		//Holder.b.setColor(Color.YELLOW);

		
		
		Holder.b.begin();
		draw();	
		Holder.b.end();
		
		update(Gdx.graphics.getDeltaTime());
	}

}
